#include<iostream>
using namespace std;
int main()
{int n,k;int a[10000];
 cin>>n;
 for(int i=1;i<=n;i++)
 {cin>>k;
  int r=0;
  for(int j=1;j<=k;j++)
    cin>>a[j];
  int t=0;
  for(int m=1;m<=k-1;m++)
    for (int n=1;n<=k-m;n++)
       {if(a[n]>a[n+1]) 
          {t=a[n];a[n]=a[n+1];a[n+1]=t;r+=1;}
       }
  cout<<"Scenario #"<<i<<":"<<endl;
  cout<<r<<endl<<endl;
 }
system("pause");
return 0;
}

       
        
  
    
    
    
    
    
    
    
    
    
    
    
    
    
    





